{include file="../include.tpl"}
<body>
{literal}
<script>
$(function() {
	setHeaderPos("用户审批");
		$( "input[type=submit],button" )
			.button()
			.click(function(event) {
			    var bid = $(event.target)[0].id;
				if(bid=="")
				{
					bid = $(event.target).parent()[0].id;
				}
				 
			    $("#ui-id-1").html("创建用户");
			    $("#name").val("");
				//alert(bid);
				if(bid.indexOf("save_")!=-1)
			    {
			        //alert("mmmm");
					$("#st_"+id).html("正在保存");
			        var id = bid.replace("save_","");
			        //window.location = "?act=wine&op=showType&wid="+id+"&name="+encodeURIComponent($("#tdName"+id).html());
					$.post("?act=user&op=update",{id:id,dbrubikenScore:$("#rubikenScore_"+id).val(),dbbabilunScore:$("#babilunScore_"+id).val(),dbbabilunTime:$("#babilunTime_"+id).val()},function(data){
						if(data.indexOf("ok")!=-1)
						{
							$("#st_"+id).html("保存成功");
 
							$("#tdtotal"+id).html(parseInt($("#tds1"+id).html())+ parseInt($("#rubikenScore_"+id).val())+parseInt($("#babilunScore_"+id).val()));
						}
						else
						{
							$("#st_"+id).html("保存失败");
						}
					});
			    }
				else if(bid=="btnQuery")
			    {
					//$("#dialog-form").dialog("open");
					window.location = "?act=user&queryName="+encodeURIComponent($("#queryName").val());
			    }
				else if(bid=="btnExport")
			    {
					//$("#dialog-form").dialog("open");)
					 
					 if($("#startDate").val()=="" || $("#endDate").val()=="")
					 {
						 alert("请选择时间");
						 return;
					 }
					 $("#st").val($("#startDate").val());
					 $("#et").val($("#endDate").val());
					  
					 $("#formExport")[0].submit();
			    }
				else if(bid.indexOf("deleteU")!=-1)
			    {
					 
				}
				else if(bid.indexOf("btnStatQuery")!=-1)
				{

					$.get("?act=user&op=ajaxStat&st="+$("#statSt").val()+"&et="+$("#statEt").val()+"&uid="+$("#qid").val(),function(d)
					{
						 alert(d);
						var j = eval("("+d+")");
						$("#showStatData").html("");
						$("#showStatData").append("<tr><td height='25'>上传文件"+j.uf+"个  发布"+j.pf+"个</td></tr>");
						$("#showStatData").append("<tr><td height='25'>上传素材包"+j.ub+"个  发布"+j.pb+"个</td></tr>");
					});
					 return false;
				}
				else if(bid.indexOf("createUser")!=-1)
				{
					$( "#dialog-form" ).dialog("open");
				}
				else if(bid.indexOf("showStat")!=-1)
				{
					$( "#dialog-form_stat" ).dialog("open");
					$("#qid").val(bid.replace("showStat_",""));
				}
				else if(bid.indexOf("showModify")!=-1)
				{
					var id = bid.replace("showModify_","");
					if(id=="1")
					{
						$("#roleId").val("1");
						$("#roleId")[0].disabled= true;
					}
					else
					{
 						$("#roleId")[0].disabled= false;
					}
					$("#editId").val(id);
					$( "#dialog-form" ).dialog("open");
					$.get("?act=user&op=ajaxGetInfo&editId="+id,function(d){
						 var j = eval("("+d+")");
						 for(var x in j)
						 {
							 if(typeof($("#"+x)[0])!="undefined")
							 {
								 if(x!="pass")
								 {
								 $("#"+x).val(j[x]);
								 }
							 }
						 }
					});
				}
				 
		});
		$( "#startDate" ).datepicker();
		 
		$( "#endDate" ).datepicker();
		$( "#dialog-form" ).dialog({
			autoOpen: false,
			height: 450,
			width: 400,
			modal: true,
			buttons: {
				"保存": function() {
					var bValid = true;
                    if($("#name").val()=="")
                    {
                       $("#td_msg_name").html("为必填项");
                       bValid = false;
                    }
                     
					if(bValid ){

					    $("#formGame")[0].submit();
					}
				},
				"取消": function() {
					$(this).dialog( "close" );
				}
			},
			close: function() {
				
			}
		});
		$("#validDate").datepicker();
		$("#roleId").change(function(){
			$("#roleName").val($(this).find("option:selected").text());
			});
		$( "#dialog-form_stat" ).dialog({
			autoOpen: false,
			height: 450,
			width: 400,
			modal: true,
			buttons: {
				"保存": function() {
					var bValid = true;
                    if($("#name").val()=="")
                    {
                       $("#td_msg_name").html("为必填项");
                       bValid = false;
                    }
                     
					if(bValid ){

					    $("#formGame")[0].submit();
					}
				},
				"取消": function() {
					$(this).dialog( "close" );
				}
			},
			close: function() {
				
			}
		});
		$("#validDate").datepicker();
		$("#statSt").datepicker();
		$("#statEt").datepicker();
		
		$("#roleId").change(function(){
			$("#roleName").val($(this).find("option:selected").text());
			});
});
function showLine(line)
{
	window.location='?act=user&queryName='+line;
	$("#src").val(line)
}
function result(i)
{
	if(i==1)
	{
		alert("保存成功");
		window.location.href=window.location.href;
	}
	else
	{
		alert("保存失败，用户名已经存在");
	}
}
</script>
{/literal}
<iframe name="iframeSubmit" id="iframeSubmit" src="about:blank" style="display:none;"></iframe>
<div id="dialog-form_stat" title="统计" style="display:none;">
	<form name="formGame" id="formGame" method="post" action="?act={$act}&op=ajaxSaveInfo" target="iframeSubmit">
	<fieldset>
       <table height="120px" width="100%">
 	   <tr><td  valign="top"><input type="text" style="display:none"/>开始时间：<input type="text" id="statSt" style="width:80px"/> 结束时间：<input type="text" id="statEt" style="width:80px"/>&nbsp;<button id="btnStatQuery">查询</button></td></tr>
       <tr>
       <td valign="top">
       <div style="height:300px; overflow:auto;">
       <table cellpadding="0" cellspacing="0" width="100%">
      
       <tbody id="showStatData">
       </tbody>
        
       </table>
       </div>
       </td>
       </tr>
       </table>
	</fieldset>
 
	<input type="hidden" id="qid" value=""/>
	</form>
</div>
<div id="dialog-form" title="添加用户" style="display:none;">
	<form name="formGame" id="formGame" method="post" action="?act={$act}&op=ajaxSaveInfo" target="iframeSubmit">
	<fieldset>
       <table height="120px" width="100%">
 	   <tr><td style="width:100px;">用户名：</td><td style="width:180px;"><input type="text" name="dbname" id="name" class="text ui-widget-content ui-corner-all" style="width:150px;"/></td><td id="td_msg_name" class="msg_txt"></td></tr>
 	   <tr><td style="width:100px;">密码：</td><td style="width:180px;"><input type="text" name="pass" id="pass" class="text ui-widget-content ui-corner-all" style="width:150px;"/></td><td id="td_msg_name" class="msg_txt"></td></tr>
       <tr><td style="width:100px;">有效期：</td><td style="width:180px;"><input type="text" name="dbvalidDate" id="validDate" class="text ui-widget-content ui-corner-all" style="width:150px;"/></td><td id="td_msg_name" class="msg_txt"></td></tr>
       <tr><td style="width:100px;">权限：</td><td style="width:180px;">
       <select name="dbroleId" id="roleId">

       <option value="2">上传</option>
       <option value="4" selected>审批</option>
       <option value="3">下载</option>
       </select>
       <input type="hidden" name="dbroleName" id="roleName" value="审批"/>
       </td><td id="td_msg_name" class="msg_txt"></td></tr>
       
       <tr><td style="width:100px;">公司名称：</td><td style="width:180px;"><input type="text" name="dbcom" id="com" class="text ui-widget-content ui-corner-all" style="width:150px;"/></td><td id="td_msg_name" class="msg_txt"></td></tr>
 	   <tr><td style="width:100px;">姓名：</td><td style="width:180px;"><input type="text" name="dbrealName" id="realName" class="text ui-widget-content ui-corner-all" style="width:150px;"/></td><td id="td_msg_name" class="msg_txt"></td></tr>
 	   <tr><td style="width:100px;">邮件：</td><td style="width:180px;"><input type="text" name="dbemail" id="email" class="text ui-widget-content ui-corner-all" style="width:150px;"/></td><td id="td_msg_name" class="msg_txt"></td></tr>
 	   <tr><td style="width:100px;">地址：</td><td style="width:180px;"><input type="text" name="dbaddress" id="address" class="text ui-widget-content ui-corner-all" style="width:150px;"/></td><td id="td_msg_name" class="msg_txt"></td></tr>
 	   <tr><td style="width:100px;">克莱斯勒负责人：</td><td style="width:180px;"><input type="text" name="dbcryFuzeren" id="cryFuzeren" class="text ui-widget-content ui-corner-all" style="width:150px;"/></td><td id="td_msg_name" class="msg_txt"></td></tr>
 	   <tr><td style="width:100px;">邮件：</td><td style="width:180px;"><input type="text" name="dbcryFuzerenEmail" id="cryFuzerenEmail" class="text ui-widget-content ui-corner-all" style="width:150px;"/></td><td id="td_msg_name" class="msg_txt"></td></tr>
 	   <tr><td style="width:100px;">申请目的：</td><td style="width:180px;"><textarea type="text" name="dbapplyDest" id="applyDest" class="text ui-widget-content ui-corner-all" style="width:150px;"></textarea></td><td id="td_msg_name" class="msg_txt"></td></tr>
       
       </table>
	</fieldset>
 
	<input type="hidden" id="editId" name="editId" value=""/>
	</form>
</div>
<form id="formExport" method="post"  action="?act=user&op=export" target="iframeSubmit"><input type="hidden" id="st" name="st"/><input type="hidden" id="et" name="et"/><input type="hidden" id="src" name="src" value="{$queryName}"/></form>
 {include file='header.tpl'}
<table width="1000" style="margin:auto;" border="0" cellpadding="0" cellspacing="0">
   
  <tr>
    
    <td valign="top" ><table width="100%" height="138" border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td height="13" valign="top">&nbsp;</td>
      </tr>
      <tr>
        <td valign="top"><table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
        {if $id eq 1}
          <tr>
            <td><table width="100%" height="35" border="0" cellpadding="0" cellspacing="0">
              <tr>
                <td width="10%" height="35" valign="middle" style="text-align:right">
                <button id="createUser">添加用户</button></td>
              </tr>
            </table></td>
          </tr>
        
		  <tr>
            <td height="20"><table width="100%" height="1" border="0" cellpadding="0" cellspacing="0" bgcolor="#CCCCCC">
              <tr><td></td></tr></table>
            </td>
          </tr>
		    {/if}
          <tr>
            <td>
            <div id="users-contain" class="ui-widget" style="width:100%;">
	<h1>用户列表:</h1> 
	<table id="users" class="ui-widget ui-widget-content">
		<thead>
			<tr class="ui-widget-header ">
            	<th style="width:40px;">ID</th>
				<th style="width:100px;">用户</th>
                <th style="width:180px;">邮件</th>
				<th style="width:50px;">手机</th>
                <th style="width:70px;">部门</th>
                <th style="width:100px;">有效期</th>
                <th style="width:55px;">状态</th>
                <th style="width:50px;">权限</th>
 				<th >操作</th>
			</tr>
		</thead>
		<tbody>
              {section name=sec1 loop=$data}
              <tr>
              <td id="tdName{$data[sec1].id}">{$data[sec1].id}</td>
              <td id="tdName{$data[sec1].id}">{$data[sec1].name}</td>
              <td id="tdName{$data[sec1].id}">{$data[sec1].email}</td>
              <td>{$data[sec1].cellphone}</td>
			  <td id="tdroleName{$data[sec1].id}">{$data[sec1].department}</td>
<td id="tds1{$data[sec1].id}">{$data[sec1].validDate}</td>
<td id="tdprice{$data[sec1].id}">{$data[sec1].st}</td>
<td id="tdprice{$data[sec1].id}">{$data[sec1].roleName}</td>
 
 <td>{if $id eq 1}<button id="showModify_{$data[sec1].id}"/>修改</button>{/if}&nbsp;&nbsp;<button id="save_{$data[sec1].id}" style="display:none;"/>激活</button><span id="st_{$data[sec1].id}"></span><button id="showStat_{$data[sec1].id}"/>统计</button></td>
              </tr>
              <input type="hidden" id="hidroleId{$data[sec1].id}" value="{$data[sec1].roleId}"/>
              <input type="hidden" id="hiddealerId{$data[sec1].id}" value="{$data[sec1].dealerId}"/>
 
              {/section}
		</tbody>
	</table><table><tr><td style="position:relative; border:none;" height="25"><div id="divPageNav" style="width:99%">{$pageNav}</div></td></tr></table>
</div>
 </td>
          </tr>
        </table>
          </td>
      </tr>
    </table></td>

  </tr>
 <tr>
        <td  colspan="3" height="30" valign="middle">
     
    </td>
  </tr>
  <tr>
        <td  colspan="3" valign="middle">
     {include file='footer.tpl'} 
    </td>
  </tr>
</table>
</body>
